package club.zhanpy.controller;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import club.zhanpy.entity.User;
import club.zhanpy.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired	
    private UserService userService;
    @RequestMapping("/showUser")
    public String toIndex(HttpServletRequest request, Model model) {
        int userId = Integer.parseInt(request.getParameter("id"));
        User user = this.userService.getUserById(userId);
        model.addAttribute("user", user);
        return "User";
    }
    @RequestMapping("/helloWorld")    
    public String helloWorld(Model model) {    
        String word0 = "Hello ";    
        String word1 = "ZHANPY!";    
        //将数据添加到视图数据容器中    
        model.addAttribute("word0",word0);    
        model.addAttribute("word1",word1);    
        return "Hello.ftl";    
    }    
}